import java.util.Vector;

public class Patient {
	
	private int id;
	private String lastName;
	private String firstName;
	private String middleName;
	private char sex;
	private int height;
	private int weight;
	private String bloodType;
	
	private String address;
	private String postalCode;
	private String city;
	private String provState;
	private String country;
	private String phone;
	
	private String emergencyLastName;
	private String emergencyFirstName;
	private String emergencyPhone; 
	
	private Vector<MedicalVisit> medicalHistory;
	private Vector<MedicalImage> medicalImages;
	private Vector<MedicalCondition> medicalConditions;
	private Vector<Medication> medications;
	
	public Patient( int id, String lastName, String firstName ) {
		
		this.id = id;
		this.lastName = lastName;
		this.firstName = firstName;
		this.middleName = "";
		this.sex = 0;
		this.height=0;
		this.weight=0;
		this.bloodType = "";
		
		this.address="";
		this.postalCode="";
		this.city="";
		this.provState="";
		this.country="";
		this.phone = "";
		
		this.emergencyFirstName="";
		this.emergencyLastName="";
		this.emergencyPhone="";
		
		medicalHistory = new Vector<MedicalVisit>();
		medicalImages = new Vector<MedicalImage>();
		medicalConditions = new Vector<MedicalCondition>();
		medications = new Vector<Medication>();
	}
	
	public String getBloodType() {
		return bloodType;
	}

	public void setBloodType(String bloodType) {
		this.bloodType = bloodType;
	}

	public String getMiddleName() {
		return middleName;
	}

	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	public char getSex() {
		return sex;
	}

	public void setSex(char sex) {
		this.sex = sex;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPostalCode() {
		return postalCode;
	}

	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getProvState() {
		return provState;
	}

	public void setProvState(String provState) {
		this.provState = provState;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getEmergencyLastName() {
		return emergencyLastName;
	}

	public void setEmergencyLastName(String emergencyLastName) {
		this.emergencyLastName = emergencyLastName;
	}

	public String getEmergencyFirstName() {
		return emergencyFirstName;
	}

	public void setEmergencyFirstName(String emergencyFirstName) {
		this.emergencyFirstName = emergencyFirstName;
	}

	public String getEmergencyPhone() {
		return emergencyPhone;
	}

	public void setEmergencyPhone(String emergencyPhone) {
		this.emergencyPhone = emergencyPhone;
	}
	
	public int getId() {
		return id;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public String getPhone() {
		return phone;
	}
	
	public void setLastName( String ln ) {
		this.lastName  = ln;
	}
	
	public void setFirstName( String fn ) {
		this.firstName = fn;
	}
	
	public void setPhone( String num ) {
		this.phone = num;
 	}
	
	public Vector<MedicalVisit> getMedicalHistory() {
		return medicalHistory;
	}
	
	public void addMedicalVisit(Date d, String doc, String des) {
		MedicalVisit v = new MedicalVisit(d, doc);
		v.setDescription(des);
		medicalHistory.add(v);
	}
	
	public Vector<MedicalImage> getMedicalImages() {
		return medicalImages;
	}
	
	public void addMedicalImage(Date d, String t, String path, String des)
	{
		MedicalImage m = new MedicalImage(d,t,path);
		m.setDescription(des);
		medicalImages.add(m);
	}
	
	public Vector<MedicalCondition> getMedicalConditions() {
		return medicalConditions;
	}
	
	public void addMedicalCondition( String name, String description ) {
		MedicalCondition m = new MedicalCondition( name, description );
		medicalConditions.add(m);
	}
	
	public Vector<Medication> getMedications() {
		return medications;
	}
	
	public void addMedication( String name, String prescribedBy, String note, boolean active ) {
		Medication m = new Medication( name, prescribedBy );
		m.setActive(active);
		m.setNotes( note );
		medications.add(m);
	}
	
	public boolean search(String criteria) {
		criteria = criteria.toLowerCase();
		if ( String.valueOf(id).toLowerCase().equals(criteria) ) return true;
		else if ( lastName.toLowerCase().indexOf(criteria) != -1 ) return true;
		else if ( firstName.toLowerCase().indexOf(criteria) != -1 ) return true;
		else if ( String.valueOf( phone ).toLowerCase().equals( criteria ) ) return true;
		
		String fullName = firstName + " " + lastName;
		if ( fullName.toLowerCase().indexOf(criteria) != -1 )  return true;
			
		return false;
	}
}
